package com.cloudlead.common.lang.security;

import com.cloudlead.common.lang.api.RequestHeaderUtils;

public final class SecurityUtils {

    public static String getUsername() {
        Subject subject = getSubject();
        if (null == subject) {
            return null;
        }
        Principal principal = subject.getPrincipal();
        if (null == principal) {
            return null;
        }
        return principal.getUsername();
    }

    public static Subject getSubject() {
        return SecurityThreadContext.getSubject();
    }

    public static String getAccessToken() {
        return RequestHeaderUtils.getAccessToken();
    }
}
